/****************************************************************************
 * Application   : Freekick Desktop Manager
 * Author        : sfreekick
 * Email         : sfreekick@gmail.com
 * Copyright     : (C) 2008 sfreekick
 * **************************************************************************/

/****************************************************************************
 *  This file is part of FreeKickManager.
 *
 *  FreeKickManager is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  FreeKickManager is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with FreeKickManager. If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace AlineacionFreeKick
{
    public class JugadorCirculo : Jugador
    {
        public JugadorCirculo() : base()
        {
        }

        public JugadorCirculo(string nombre, int x, int y) : base(nombre, x, y)
        {
        }

        public JugadorCirculo(string nombre, int x, int y, int ancho, int alto)
            : base(nombre, x, y, ancho, alto)
        {
        }

        public override void draw(Graphics g)
        {
            Pen p = new Pen(Color.Black, 1);
            Brush b = new SolidBrush(Color.Yellow);
            Brush bo = new SolidBrush(Color.Orange);
            Brush bs = new SolidBrush(Color.Black);
            Brush bw = new SolidBrush(Color.White);

            //Dibujo del cuadro
            if(posicion == PosicionJugador.NINGUNA)
                g.FillEllipse(bo, x + ancho / 2 - alto / 2, y, alto, alto);
            else
                g.FillEllipse(b, x + ancho / 2 - alto / 2, y, alto, alto);

            g.DrawEllipse(p, x + ancho / 2 - alto / 2, y, alto, alto);

            //Dibujo del nombre
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            g.DrawString(nombre,new Font("Arial",7),bw,new Rectangle(x,y+alto,ancho,alto),sf);
        }

        public override bool hit(int cx, int cy)
        {
            if (cx > (x + ancho / 2 - alto / 2) && cx < (x + ancho / 2 - alto / 2 + alto) && cy > y && cy < (y + alto))
                return true;

            return false;
        }

        public override Rectangle getRectangle()
        {
            return new Rectangle(x, y, ancho, 2*alto);
        }

        public override Point getCentro()
        {
            return new Point(x + alto / 2, y + alto / 2);
        }

        public override Rectangle getZonaActiva()
        {
            return new Rectangle(x + ancho / 2 - alto / 2, y, alto, alto);
        }

        public override void setCentro(int x, int y)
        {
            this.x = x - ancho / 2;

            this.y = y - alto / 2;

            //if (posicion == PosicionJugador.POR)
            //    this.y = y - alto / 4;
            //else
            //    this.y = y - alto / 5;
        }
    }
}
